<?php
	/*$allowedExts = array("jpg", "jpeg", "png");
	$extension = end(explode(".", $_FILES["file"]["name"]));
	if ((($_FILES["file"]["type"] == "image/png")
	|| ($_FILES["file"]["type"] == "image/jpeg")
	|| ($_FILES["file"]["type"] == "image/pjppeg"))
	&& ($_FILES["file"]["size"] < 400000)
	&& in_array($extension, $allowedExts))
	  {
	  if ($_FILES["file"]["error"] > 0)
	    {
	    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
	    }
	  else
	    {
	    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
	    echo "Type: " . $_FILES["file"]["type"] . "<br />";
	    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
	    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
	
	    if (file_exists("files/" . $_FILES["file"]["name"]))
	      {
	      echo $_FILES["file"]["name"] . " already exists. ";
	      }
	    else
	      {
	      move_uploaded_file($_FILES["file"]["tmp_name"],
	      "files/" . $_FILES["file"]["name"]);
	      echo "Stored in: " . "files/" . $_FILES["file"]["name"];
	      }
	    }
	  }
	else
	  {
	  echo "Invalid file";
	  }*/
?>

<!doctype html>
<html lang="sv">
	<head>
		<meta charset="utf-8" />
    	<title>Bajs</title>
   		<link rel="stylesheet" href="css/style.css">
  	</head>
	<body>
		<form action='FileUploadHandler.php' method='post' enctype='multipart/form-data'>
			<div id='formUpload'>
				<p><input type='file' name='file' id='file' /></p>
				<p><input type='submit' name='submit' value='Upload' /></p>
			</div>
		</form>
		<?php
			$dir = opendir("files");

			while (($file = readdir($dir)) !== false)
			  {
			  	echo  "<img src='files/$file' height='50px' width='100px'>";
			  }
			closedir($dir);
		?>
	</body>
</html>
